-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply runtime library workaround for snapshot toolchains on macOS #484
Conversation
guard fileSystem.isFile(file) else { continue } | ||
|
||
let process = Foundation.Process() | ||
process.executableURL = URL(fileURLWithPath: "/usr/bin/sudo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need sudo as long as the toolchain is installed under ~/Library/Toolchain/
if I remember correctly, and we can assume it's installed there by carton
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あ、そうなの
試してみます
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self comment
printsLoadingMessage: Bool = true, | ||
forwardExit: Bool = false | ||
) throws { | ||
let process = Foundation.Process() | ||
process.executableURL = executableURL | ||
process.arguments = arguments | ||
process.environment = environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkRunに環境変数の設定する口を開けました。
let pluginArguments = try derivePackageCommandArguments( | ||
swiftExec: swiftExec, | ||
subcommand: subcommand, | ||
scratchPath: scratchPath.path, | ||
extraArguments: extraArguments | ||
) | ||
|
||
var env: [String: String] = ProcessInfo.processInfo.environment | ||
if ToolchainSystem.isSnapshotVersion(swiftPath.verison), | ||
swiftPath.toolchain.extension == "xctoolchain" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mac環境かつsnapshotなら、DYLD...
を設定します。
@@ -12,7 +12,9 @@ | |||
// See the License for the specific language governing permissions and | |||
// limitations under the License. | |||
|
|||
#if compiler(>=5.10) | |||
#if compiler(>=6.0) | |||
public let defaultToolchainVersion = "wasm-6.0-SNAPSHOT-2024-06-08-a" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6.0のsnapshotを追加します。
CIのSwift6.0が swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-07-a
になっていて、
それと対応する wasm swift にしています。
だから1日ズレています。
@@ -94,7 +94,6 @@ extension Process { | |||
|
|||
switch result.map(\.exitStatus) { | |||
case .success(.terminated(code: EXIT_SUCCESS)): | |||
terminal.write("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この改行が不要そうでした。
@@ -103,7 +102,7 @@ extension Process { | |||
terminal.write(stdoutBuffer) | |||
} | |||
terminal.write( | |||
"\n`\(processName)` process finished successfully\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この冒頭の改行も不要だと思いました。
@@ -65,6 +66,8 @@ extension ToolchainSystem { | |||
stream: stdoutStream, | |||
header: "Downloading the archive" | |||
) | |||
defer { terminal.write("\n") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ダウンロードが完了した時
Download completed successfully
のメッセージが saving to ...
の右に表示されていておかしかったので、改行を入れます。
ここはターミナルがアニメーションするループがあるので、
エラーの場合もうまくいくように
defer でここに書きます。
@@ -109,6 +112,32 @@ extension ToolchainSystem { | |||
terminal.logLookup("Unpacking the archive: ", arguments.joined(separator: " ")) | |||
try await Process.run(arguments, terminal) | |||
|
|||
if ext == "pkg", Self.isSnapshotVersion(version) { | |||
try await patchSnapshotForMac(path: installationPath, terminal: terminal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
インストール後にmacでsnapshotならパッチ(再署名)します。
for file in try fileSystem.traverseRecursively(binDir) { | ||
guard fileSystem.isFile(file) else { continue } | ||
|
||
try Foundation.Process.checkRun( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
出力がスッキリするので Foundation.Process.checkRun
を使いました。
public var verison: String | ||
public var swift: AbsolutePath | ||
public var toolchain: AbsolutePath | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
従来、swiftとバージョンのタプルでしたが、
ツールチェーンディレクトリも使いたくなったので追加します。
ついでにタプルをやめて型にすることで利用側のコードを読みやすくします。
あれ、CI失敗だ
|
printsLoadingMessage: Bool = true, | ||
forwardExit: Bool = false | ||
) throws { | ||
let process = Foundation.Process() | ||
process.executableURL = executableURL | ||
process.arguments = arguments | ||
if let environment { | ||
process.environment = environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
環境変数を設定する口を開けました。
nil
をセットすると、
継承するデフォルト挙動が消えるようなので、
nilの時はifで避けます。
参考:
https://developer.apple.com/documentation/foundation/process/1409412-environment
If this method isn’t used, the environment is inherited from the process that created the receiver
だめだあ |
17a436f
to
b398cfe
Compare
} else { | ||
let programName = (program as NSString).lastPathComponent | ||
if programName == "wasmtime" { | ||
arguments += ["--dir", "."] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wasmtimeのpreopenの問題の対応
swiftlang/swift#73327 (comment) のハックを Carton に組み込む
動作の様子
コード署名し直すことを黄色で予告して、コマンドラインを表示しました。
また、ついでに見た目の改善としてコマンドライン実行時の不足している改行を追加したり、余計な空行を削除したりしました。